import { request } from '@/utils/request';

import type { AliOssModel,UploadResultModel } from '@/api/model/uploadModel';
 

const Api = {
  Local:'/storage/local',
  AliOssToken: '/storage/aliyun/ststoken',
  ImageAudit: '/storage/douyin/audit',
  AliyunUrl: '/storage/aliyun/url',
};
//本地存储
export function upload(d:any){
  request.setHeader({"Content-Type":"multipart/form-data"});

  for(let i=0;i<d.length;i++)
  {
    const formData=new FormData();
    formData.append("files",d[i])
    return request.post<Array<UploadResultModel>>({
      url:Api.Local,
      data:formData
    });
  }
}


//阿里云 oss sts
export function fetchAliOssSTS() {
  return request.get<AliOssModel>({
    url: Api.AliOssToken,
  });
}

//抖音图片审核
export function auditImage(d: any) {
  return request.post<Boolean>({
    url: Api.ImageAudit,
    data: d,
  });
}

//获取阿里云信息
export function aliyunUrl(key: string) {
  return request.get<string>({
    url: Api.AliyunUrl + '?key=' + key,
  });
}
